unit DnevnikRDM;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  DBClient, StdVcl, FMTBcd, Provider, alProvider, DB, SqlExpr,
  PoslovanjeSrv_TLB,
  TemeljnicaRDM;

type
  TrdmDnevnik = class(TrdmTemeljnica, IrdmDnevnik)
  private
    { Private declarations }
  protected
    class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
    function GetSelectCommandText(DataSet: TSQLDataSet): string; override;
    function Get_RazredID(const ProviderName: WideString): Integer; safecall;
    function GetTableName: string; override;
    function Get_Saldo(ID: Integer): Double; safecall;
    procedure Set_ReadOnly(Value: WordBool); safecall;
    procedure Set_SQLConnection(Value: Integer); safecall;
    procedure PrenosGlavnaKnjiga(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
    procedure PrenosKnjigaIzdanihRacunov(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
    procedure PrenosKnjigaPrejetihRacunov(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
    procedure RefreshRecord(const Session: ISession;
      const ProviderName: WideString; ID: Integer); safecall;
    procedure Renumber(const Session: ISession; const FieldName,
      SortFieldName: WideString; StartValue, EndValue: Integer); safecall;
    procedure StornoPrenosGlavnaKnjiga(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
    procedure StornoPrenosKnjigaIzdanihRacunov(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
    procedure StornoPrenosKnjigaPrejetihRacunov(const Session: ISession;
      SelectionType: Integer; StevilkeDokumentov: OleVariant); safecall;
  public
    constructor Create(AOwner: TComponent); override;
  end;

var
  DnevnikFactory: TComponentFactory;

implementation

{$R *.DFM}

constructor TrdmDnevnik.Create(AOwner: TComponent);
begin
  inherited;
  dspMain.Options := dspMain.Options + [poReadOnly];
end;

function TrdmDnevnik.GetSelectCommandText(DataSet: TSQLDataSet): string;
var
  SQL: TStringList;
begin
  SQL := TStringList.Create;
  try
    if DataSet = dsMain then
    begin
      SQL.Add('select');
        SQL.Add('DNE.*');
      SQL.Add('from DNEVNIK DNE');
      SQL.Add('where DNE.REF_ID = :POSLOVNO_LETO_ID');
    end
    else if DataSet = dsPostavka then
    begin
      SQL.Add('select');
        SQL.Add('DPO.*');
      SQL.Add('from DNEVNIK_POSTAVKA DPO');
    end;
  finally
    Result := Trim(SQL.Text);
    SQL.Free;
  end;
end;

function TrdmDnevnik.GetTableName: string;
begin
  Result := 'DNE';
end;

function TrdmDnevnik.Get_RazredID(const ProviderName: WideString): Integer;
begin
  Result := inherited Get_RazredID(ProviderName);
end;

function TrdmDnevnik.Get_Saldo(ID: Integer): Double;
begin
  Result := inherited Get_Saldo(ID);
end;

procedure TrdmDnevnik.PrenosGlavnaKnjiga(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.PrenosKnjigaIzdanihRacunov(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.PrenosKnjigaPrejetihRacunov(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.RefreshRecord(const Session: ISession;
  const ProviderName: WideString; ID: Integer);
begin
  inherited;
end;

procedure TrdmDnevnik.Renumber(const Session: ISession; const FieldName,
  SortFieldName: WideString; StartValue, EndValue: Integer);
begin
  inherited;
end;

procedure TrdmDnevnik.StornoPrenosGlavnaKnjiga(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.StornoPrenosKnjigaIzdanihRacunov(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.StornoPrenosKnjigaPrejetihRacunov(const Session: ISession;
  SelectionType: Integer; StevilkeDokumentov: OleVariant);
begin
  inherited;
end;

procedure TrdmDnevnik.Set_ReadOnly(Value: WordBool);
begin
  inherited;
end;

procedure TrdmDnevnik.Set_SQLConnection(Value: Integer);
begin
  inherited;
end;

class procedure TrdmDnevnik.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
  if Register then
  begin
    inherited UpdateRegistry(Register, ClassID, ProgID);
    EnableSocketTransport(ClassID);
    EnableWebTransport(ClassID);
  end else
  begin
    DisableSocketTransport(ClassID);
    DisableWebTransport(ClassID);
    inherited UpdateRegistry(Register, ClassID, ProgID);
  end;
end;

initialization
  DnevnikFactory := TComponentFactory.Create(ComServer, TrdmDnevnik,
    Class_rdmDnevnik, ciInternal, tmApartment);
end.
